package auth_middleware

import (
	"gvb_service/common"
	"gvb_service/util"

	"github.com/gin-gonic/gin"
)

func AuthMiddleware(c *gin.Context) {
	token := c.GetHeader("token")
	if token == "" {
		common.Fail(c, nil, "token不能为空")
		c.Abort()
		return
	}
	if util.ParseToken(token) == "" {
		common.Fail(c, nil, "token无效")
		c.Abort()
		return
	}
	c.Next()
}
